package com.lovo.csc.controller;


import com.lovo.csc.dto.PurchaseInfoDto;
import com.lovo.csc.entity.Purchase;
import com.lovo.csc.service.IPurchaseService;
import com.lovo.csc.service.IPurchasetenderService;
import com.lovo.util.MQUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.w3c.dom.stylesheets.LinkStyle;

import java.util.List;

/**
 * <p>
 *  采购信息
 * </p>
 *
 * @author lovo
 * @since 2022-07-07
 */
@RestController
@RequestMapping("/purchase")
@Api(value = "采购审核,舒得强")
public class PurchaseController {
    @Autowired
    IPurchaseService purchaseService;

    @Autowired
    RabbitTemplate rabbitTemplate;
    @GetMapping("findAll")
    @ApiOperation("查询出采购信息表的数据")
    public List<Purchase> findAll(){
        List<Purchase> findAll = purchaseService.list();
        return  findAll;
    }

    @PostMapping("PurchaseInfo")
    @ApiOperation("返回采购单审核过后的返回值")
    public boolean PurchaseInfo(PurchaseInfoDto purchaseInfoDto){
        if (purchaseInfoDto!=null){
            rabbitTemplate.convertAndSend(MQUtil.PurchaseInfoDirectExchange,MQUtil.PurchaseInfoKey,purchaseInfoDto);
        }
        return true;
    }
}
